package mysql

import (
	"github.com/go-xorm/xorm"
	"note/service/repository"
)

type schoolsRepository struct {
	db *xorm.Engine
}

func NewSchoolRepository(db *xorm.Engine) repository.SchoolsRepository {
	return &schoolsRepository{db: db}
}

func (self *schoolsRepository) InsertOne(doc *repository.Schools) (id int64, err error) {
	return self.db.InsertOne(doc)
}

func (self *schoolsRepository) FindById(filter interface{}) (*repository.Schools, error) {
	doc := &repository.Schools{}
	_, err := self.db.Where("id=?", filter).Get(doc)
	return doc, err
}
func (self *schoolsRepository) FindFilter(str string, args ...interface{}) ([]*repository.Schools, error) {
	var docs []*repository.Schools
	err := self.db.Where(str, args...).Find(&docs)
	return docs, err
}
